package com.chl.legou.item.controller;

import com.chl.legou.core.controller.BaseController;
import com.chl.legou.item.po.Category;
import com.chl.legou.item.service.ICategoryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;
import java.util.List;

@RestController
@RequestMapping("/category")
public class CategoryController extends BaseController<ICategoryService, Category> {
    @ApiOperation(value = "根据ids查询names",notes = "根据id查询列表")
    @GetMapping("/names")
    public ResponseEntity<List<String>> queryNamesByIds(@PathParam("ids") List<Long> ids){
        List<String> names = service.selectNameByIds(ids);

        if(null == names || names.size() == 0){
            return new ResponseEntity<>(HttpStatus.NO_CONTENT);
        }
        return ResponseEntity.ok(names);
    }

}
